package com.ux.iot.core.service.scan;

import com.ux.iot.core.annotation.MessageListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Set;

@Slf4j
public class IotScanner extends ClassPathBeanDefinitionScanner {

    public IotScanner(BeanDefinitionRegistry registry) {
        super(registry, true);
    }
    @Override
    protected void registerDefaultFilters() {
        //扫描规则
        this.addIncludeFilter(new AnnotationTypeFilter(MessageListener.class));
        this.addExcludeFilter(new AnnotationTypeFilter(RequestMapping.class));
    }
    @Override
    public Set<BeanDefinitionHolder> doScan(String... basePackages) {
        Set<BeanDefinitionHolder> set=super.doScan(basePackages);
        log.info("需要加载的类{}",  set.toArray());
        return set;
    }

}

